Include Yaa’s
As another one of our exploratory analyses, we thought it would be interesting to examine whether the length of time of the reported event or crime differs by borough. Examining the length of the reported event or crime can serve as a proxy indicator of the severity of the crime by each borough, assuming that longer crimes tend to be more severe, harder to resolve, and requiring more resources to deal with.
First, we loaded the required R packages. Next, we read in the CSV file and tidied it up. After running a density plot on the variable time_diff2 (length of reported crime/event in days) and viewing some summary statistics, we noticed that most of the values of that variable seemed to fall under “0.” We also noticed a high number of missing values. As a result, we excluded missing values and only looked at observations for which time_diff2 > 0. The number of observations was large and sufficient enough to observe any patterns - our final analytic sample included 2,682 observations.
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## 0.000 0.000 0.000 4.859 0.000 1179.958 9108

We looked at the data in a data table to examine general trends and get a feel of the data. Our data cleaning seemed to work. We also decided to find the average length of reported event for each borough.
=======
As another one of our exploratory analyses, we thought it would be interesting to examine whether the length of time of the reported felony differed by borough. Examining the length of the reported felony can serve as a proxy indicator of the severity of the crime by each borough - longer felonies may tend to be more severe, harder to resolve, more violent, and may require more resources to deal with. Furthermore, differences in the length of reported felonies may have implications for law enforcement officials, policymakers, and urban residents.
First, we loaded the required R packages. Next, we read in the CSV file and tidied it up. After running a density plot on a newly created variable called time_diff2 (length of reported felony in days) and viewing some summary statistics, we noticed that most of the values of that variable seemed to fall under “0,” heavily skewing the data. We also noticed a high number of missing values. As a result, we excluded missing values and only looked at observations for which time_diff2 > 0, which allowed us to more clearly visualize and understand our data. The number of observations was still large and sufficient enough to observe any patterns - our final analytic dataset, crime_data2, included 2,682 observations. As a reminder, note that only sex-related, weapons-related, and drug-related felonies are analyzed.

We first looked at the data in a data table to examine general trends and get a feel of the data; specifically, we examined the average length of a reported felony for each borough in a data table - based on this, there seems to be a marked difference in the average length across boroughs. For example, average length of reported crimes ranged from 58.52 days (Manhattan) to 105.42 days (Staten Island) across all the years and across weapons-related, drug-related, and sex-related felonies.
>>>>>>> e3d0c7d063a98a3751805f2fb2baec49e7b72ef0| Borough | mean_time |
|---|---|
| bronx | 71.31 |
| brooklyn | 60.91 |
| manhattan | 58.52 |
| queens | 78.63 |
| staten_island | 105.42 |
Next, we looked at whether the length of time for the reported event/crime differed by borough visually. I examine both the average length of time of reported events across boroughs; I also view each individual reported event’s length of time across borough. 

From the graph above, we can see a couple of things. First, there are, numerically speaking, fewer reported events in Staten Island. Secondly, the spread of the reported events seems to be slightly larger in Manhattan than in other boroughs. Lastly, the spread among Brooklyn and Queens is approximately the same.
You can find the code for this exploratory analysis here.
Next, we visually investigated at whether the length of time for the reported felony differed by borough. We examined both the average length of time of reported felonies across boroughs, as well as each individual reported felony’s length of time across boroughs. 

We obtain a rich amount of information from the graphs above. First, regarding the average length of reported felonies, Staten Island clearly outranks the other borough, leading at 105.42 days. Queens is next (78.63 days), followed by the Bronx (71.31 days), Brooklyn (60.91 days), and Manhattan (58.52 days).
One reason that may account for Staten Island’s rank is that the borough has fewer observations compared to the other boroughs, so any outliers in Staten Island may easily and drastically skew the average. Another potential reason is that criminals may be more comfortable committing felonies in a borough that is less populated with other residents and law enforcement officials. Manhattan, on the other hand, is a more crowded borough - perhaps criminals feel less comfortable committing a felony in such an area. This may be particularly relevant and true if felonies are more severe or violent, and criminals need time, space, and less attention when committing these crimes. Indeed, we may be right - felonies comprise a more violent category, in relation to misdemeanors; felonies tend to include homicide, rape, robbery, arson, human trafficking, and so on.
Regarding the length of each reported felony across boroughs, we see that Bronx, Brooklyn, Manhattan, and Queens have significantly more outliers (and thus, perhaps more observations) compared to Staten Island, giving a bit more credence to the first hypothesis stated above. We also notice that the median values, which tend to be a more stable measure against outliers than the mean, are close to 0 for all the boroughs, suggesting that many felonies still last around a single day despite our filtering out same-day felonies. Despite this, Staten Island still shows a median value that seems slightly above the values of the other boroughs.
>>>>>>> e3d0c7d063a98a3751805f2fb2baec49e7b72ef0
For our third exploratory analysis, we chose to examine crime (i.e., felony) rates by borough. Doing so gives us an understanding as to how NYPD can prioritize their efforts when stemming crime.
First, we loaded information from the U.S. Census on total population in the individual NYC boroughs to calculate felony rates in each borough.
Next, we plotted the overall felony rates over 2014-2017 for each borough.
<<<<<<< HEAD ======= >>>>>>> e3d0c7d063a98a3751805f2fb2baec49e7b72ef0From the graph above, we notice some interesting findings. First, Bronx, by far, has had the highest overall felony rate from 2014-2017. Secondly, the felony rates for Brooklyn and Manhattan are very similar; this applies to Queens and Staten Island as well, which comprise the two boroughs with the lowest overall crime rates from 2014-2017. Third, we can see that felony rates decreased from 2016-2017 for all boroughs except for Brooklyn. Lastly, overall felony rates across the years for all boroughs have tended to be stable, generally speaking. Note that these are strictly sex-related, weapons-related, and drug-related felonies.
Our final exploratory analysis examined the geographical distribution of felonies. Examining this gives us information regarding the absolute numbers of felonies in each borough, and again, helps law enforcement officials determine where to prioritize efforts.
<<<<<<< HEAD ======= >>>>>>> e3d0c7d063a98a3751805f2fb2baec49e7b72ef0

Bronx has consistently had the highest crime rate over the last 4 years for all 3 types of crimes. We see a steep reduction, however, in the crime rate for the Bronx between the years of 2016 and 2017. Crime rates for all crimes in all boroughs decreased from 2016 to 2016. Surprisingly, Brooklyn has seen a consistent rise in the crime rate of drug related felonies from 2015 to 2017.